<template>
  <van-cell class="article-item-container" :to="`/article/${article.art_id}`">
    <!-- :to="`/article/${article.art_id}`" 以上文章id固定住，以便后续设置图片功能 -->
    <!-- 文章标题 -->
    <template #title>
      <div class="title">{{ article.title }}</div>
    </template>

    <!-- 底部信息 -->
    <template #label>
      <div class="con_middle">
        <div class="art_desc">{{ article.con }}</div>
        <!-- 图片区域 -->
        <div v-show="article.cover" class="cover-wrap">
          <van-image
            class="cover-image"
            :src="article.cover"
            fit="cover"
          />
        </div>
      </div>
      <!-- 作者信息 -->
      <div class="info">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }} 评论</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </template>

    <!-- 右侧图片 -->
    <!-- 当图片数量为1时，才展示该区域 => article.cover.type === 1 -->
    <template #default v-if="article.cover.type === 1">
      <van-image
        :src="article.cover.images[0]"
        fit="cover"
        class="article-image"
      />
    </template>
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: {
    article: { // 当前文章简介
      type: Object,
      default: () => ({})
    }
  }
}
</script>

<style scoped lang="less">
.article-item-container {

  .title {
    font-size: 17px;
    padding: 5px 0;
    font-weight: bold;
  }

  .van-cell__label {
    .con_middle {
      display: flex;

      .art_desc {
        font-size: 11px;
        padding-right: 15px;
      }

      ::v-deep .cover-wrap {
        .cover-image {
          width: 85px;
          height: 85px;

          img {
            border-radius: 10px;
          }
        }
      }
    }

    .info {
      margin-top: 12px;

      span {
        margin-right: 6px;
      }
    }
  }

  .van-cell__value {
    flex: unset;

    .article-image {
      width: 116px;
      height: 73px;
    }
  }
}
</style>
